package com.ruoyi.bizsys.controller;

import java.util.List;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bizsys.domain.NextStepCrs;
import com.ruoyi.bizsys.service.INextStepCrsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 规则集2crsController
 *
 * @author african-loan
 * @date 2021-12-30
 */
@RestController
@RequestMapping("/bizsys/crs")
public class NextStepCrsController extends BaseController {
    @Autowired
    private INextStepCrsService nextStepCrsService;

/**
 * 查询规则集2crs列表
 */
@PreAuthorize("@ss.hasPermi('bizsys:crs:list')")
@GetMapping("/list")
        public TableDataInfo list(NextStepCrs nextStepCrs) {
        startPage();
        List<NextStepCrs> list = nextStepCrsService.selectNextStepCrsList(nextStepCrs);
        return getDataTable(list);
    }
    
    /**
     * 导出规则集2crs列表
     */
    @PreAuthorize("@ss.hasPermi('bizsys:crs:export')")
    @Log(title = "规则集2crs", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(NextStepCrs nextStepCrs) {
        List<NextStepCrs> list = nextStepCrsService.selectNextStepCrsList(nextStepCrs);
        ExcelUtil<NextStepCrs> util = new ExcelUtil<NextStepCrs>(NextStepCrs.class);
        return util.exportExcel(list, "crs");
    }

    /**
     * 获取规则集2crs详细信息
     */
    @PreAuthorize("@ss.hasPermi('bizsys:crs:query')")
    @GetMapping(value = "/{crsId}")
    public AjaxResult getInfo(@PathVariable("crsId") Long crsId) {
        return AjaxResult.success(nextStepCrsService.selectNextStepCrsById(crsId));
    }

    /**
     * 新增规则集2crs
     */
    @PreAuthorize("@ss.hasPermi('bizsys:crs:add')")
    @Log(title = "规则集2crs", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NextStepCrs nextStepCrs) {
        return toAjax(nextStepCrsService.insertNextStepCrs(nextStepCrs));
    }

    /**
     * 修改规则集2crs
     */
    @PreAuthorize("@ss.hasPermi('bizsys:crs:edit')")
    @Log(title = "规则集2crs", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NextStepCrs nextStepCrs) {
        return toAjax(nextStepCrsService.updateNextStepCrs(nextStepCrs));
    }

    /**
     * 删除规则集2crs
     */
    @PreAuthorize("@ss.hasPermi('bizsys:crs:remove')")
    @Log(title = "规则集2crs", businessType = BusinessType.DELETE)
    @DeleteMapping("/{crsIds}")
    public AjaxResult remove(@PathVariable Long[] crsIds) {
        return toAjax(nextStepCrsService.deleteNextStepCrsByIds(crsIds));
    }
}
